﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using CodeCampServerLite.Core.Domain;
using CodeCampServerLite.Core.Domain.Model;
using CodeCampServerLite.UI.Helpers;
using CodeCampServerLite.UI.Models;

namespace CodeCampServerLite.UI.Controllers
{
    public class AttendeeController : DefaultController
    {
        private readonly IConferenceRepository _repository;
    	private readonly IObjectMapper _mapper;

    	public AttendeeController(IConferenceRepository repository, IObjectMapper mapper)
        {
        	_repository = repository;
        	_mapper = mapper;
        }

    	public ActionResult Show(string confname)
        {
            var conference = _repository.GetByName(confname);
    		var attendees = conference.GetAttendees();

    		var viewModel = _mapper.Map<IEnumerable<Attendee>, ConferenceShowModel.AttendeeModel[]>(attendees);

            return View(viewModel);
        }
    }
}